package step2;

import com.sun.org.apache.bcel.internal.classfile.Code;

import java.io.*;

public class Experiment implements Serializable,Cloneable {
    private String name;
    private String teacher;
    private String describe;
    private Codefile file;

    public Codefile getFile() {
        return file;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTeacher() {
        return teacher;
    }

    public void setTeacher(String teacher) {
        this.teacher = teacher;
    }

    public String getDescribe() {
        return describe;
    }

    public void setDescribe(String describe) {
        this.describe = describe;
    }
    public String toString(){
        return "Experiment[teacher="+teacher+",name="+name+",describe="+describe+"]";
    }
    public Experiment(Codefile file){
        this.file =file;
    }
    public Object DeepClone() throws IOException, ClassNotFoundException, OptionalDataException, CloneNotSupportedException {
        /********** Begin *********/
        //将对象写入流中
        Experiment clonedExperiment = (Experiment) super.clone();
        if(this.file != null){
            Codefile codefile = clonedExperiment.getFile().clone();
        clonedExperiment.file = codefile;
        }

//        if(this.file != null){
//            clonedExperiment.file = (Codefile) this.file.clone(); }


        clonedExperiment.name = this.name;
        clonedExperiment.teacher = this.teacher;
        clonedExperiment.describe = this.describe;
        return clonedExperiment;
        //将对象从流中取出
        /********** End *********/

    }
}
